/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */


package br.ufmg.dees.insane.xyplot.xyplot_model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

import br.ufmg.dees.insane.util.IPoint3d;

/**
 * @author  Penna, Samuel  TODO To change the template for this generated type comment go to  Window - Preferences - Java - Code Style - Code Templates
 */
public class ISequence implements Serializable{

/**
     * Comment for <code>serialVersionUID</code>
     */
    private static final long serialVersionUID = 1L;

/** The label of this Sequence. */	
protected String label;

/** An ArrayList containing all Points of this Sequence. */
protected List<IPoint3d> pointsList = new ArrayList<IPoint3d>();

/** The inferior limit of this Sequence. */	
protected IPoint3d infLimit;

/** The superior limit of this Sequence. */
protected IPoint3d supLimit; 

//******************************************************************************

 /** Constructs a Sequence , sets its label to aLabel and its iferior and superior limits to iLimit and sLimit.*/
 public ISequence(String aLabel, List<IPoint3d> points, IPoint3d iLimit, IPoint3d sLimit){

  label = aLabel;
  pointsList = points;
  infLimit = iLimit;  
  supLimit = sLimit;
  	
 }

 public ISequence(){}

//******************************************************************************

/**
 * Returns the label of this Sequence.
 * @return  The label of this Sequence.
 * @uml.property  name="label"
 */
 public String getLabel(){
	return label;
}

/**
 * Sets the label of this Sequence.
 * @param newLabel  The Label of this Sequence.
 * @uml.property  name="label"
 */
 public void setLabel(String newLabel ){
	label = newLabel;
}

//******************************************************************************	

 /**
 * Returns the list of points of this Sequence.
 * @return  The list of points of this Sequence.
 * @uml.property  name="pointsList"
 */
 public List<IPoint3d> getPointsList() {
	return pointsList;
}

 /** Sets the list of points of this Sequence.
  *  @param pts The list of points of this Sequence.
  */
 public void setPointsList(ArrayList<IPoint3d> pts) {
	pointsList = pts;
 }

 //******************************************************************************
 
 /** Returns the number of points of this Sequence.
  *  @return The number of points of this Sequence.
  */
 public int getNumberOfPoints(){
	return (pointsList.size());
 }
	
//*******************************************************************************
 
 /**
 * Returns the inferior Limit of this Sequence.
 * @return  The infLimit of this Sequence.
 * @uml.property  name="infLimit"
 */
 public IPoint3d getInfLimit(){
	return infLimit;
}

 /**
 * Sets the inferior Limit of this Sequence.
 * @param newInfLimit  The inferior Limit of this Sequence.
 * @uml.property  name="infLimit"
 */
 public void setInfLimit(IPoint3d newInfLimit){
	infLimit = newInfLimit;
}
 
//*******************************************************************************

 /**
 * Returns the superior Limit of this Sequence.
 * @return  The supLimit of this Sequence.
 * @uml.property  name="supLimit"
 */
 public IPoint3d getSupLimit(){
	return supLimit;
}
 
 /**
 * Sets the superior Limit of this Sequence.
 * @param newSupLimit  The superior Limit of this Sequence.
 * @uml.property  name="supLimit"
 */
 public void setSupLimit(IPoint3d newSupLimit){
	supLimit = newSupLimit;
}

//*******************************************************************************

 /** Add a point in this Sequence.
  *  @param aPoint The point which will be add in this Sequence.
  */
 public void add(IPoint3d aPoint){	
 	pointsList.add(aPoint);
 }
 
//*****************************************************************************

 /** Add a point in specifeid positon in this Sequence.
  *  @param aPoint The point which will be add in this Sequence.
  *  @param index The position of the point which will be add.
  */
 public void add(int index ,IPoint3d aPoint){	
 	pointsList.add(index,aPoint);
 }
 
//*****************************************************************************

 /** Remove a point of this Sequence.
  *  @param aPoint The point which will be removed.
  */	
 public void remove(IPoint3d aPoint){
 	IPoint3d pt;
	ListIterator pts = pointsList.listIterator();
	while (pts.hasNext()) {
		pt = (IPoint3d)pts.next();
		if (pt.equals(aPoint)){
			pts.remove();
		}
	}
 }

//******************************************************************************

 /** Remove a point at the specified position in this Sequence.
  *  @param index The position of the point which will be removed.
  */	
 public void remove(int index) {
	pointsList.remove(index);
 }

//*****************************************************************************
 
 /** Returns the point at the specified position in this Sequence.
  *  @return The point specified of this Sequence.
  */
 public IPoint3d getPoint(int index) {
	return (IPoint3d)pointsList.get(index);
 }

 /** Sets the point at the specified position in this Sequence.
  *  @param index The position of the point which will be set.
  *  @param pt The point of this Sequence.
  */
 public void setPoint(int index, IPoint3d pt) {
	pointsList.set(index, pt);
 }

//*****************************************************************************

 /** Returns the position of a specified point in this Sequence.
  *  @param p The point of this Sequence.
  */
 public int indexOf(IPoint3d p) {
		int index = -1;
		IPoint3d pt;
		ListIterator pts = pointsList.listIterator();
		while (pts.hasNext()) {
			pt = (IPoint3d)pts.next();
			if (pt.equals(p)){
				index = pointsList.indexOf(pt);
			}
		}
	return index;
 }
	
//*****************************************************************************
 
 /** Remove all points from this list.*/	
 public void clearPoints() {
	pointsList.clear();
 }
//*****************************************************************************
	
}